package leetcode.code0944;

import java.util.LinkedList;
import java.util.Queue;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int minDeletionSize(String[] strs) {
		int size = strs[0].length();
		Queue<Integer> idxs = new LinkedList<>();
		for (int i = 0; i < size; i++) {
			idxs.add(i);
		}
		int ans = 0;
		char[] hash = new char[size];
		for (int i = 0; i < strs.length; i++) {
			char[] cs = strs[i].toCharArray();
			int cnt = idxs.size();
			while (cnt > 0) {
				int idx = idxs.poll();
				if (cs[idx] >= hash[idx]) {
					hash[idx] = cs[idx];
					idxs.add(idx);
				} else if (cs[idx] < hash[idx]) {
					ans++;
				}
				cnt--;
			}
		}
		return ans;
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
